<?php defined('SYSPATH') or die('No direct script access.');

class logger {
    
    public static function securityAlert($message) {
    	self::security('alert', $message);
    }
    
    private static function security($level, $message) {
    	$sessionData = SessionData::instance();
    	$log = $_SERVER['REMOTE_ADDR'] . ' (' . $_SERVER['REMOTE_HOST'] . '): ';
    	if ($sessionData) {
    		$person = $sessionData->getAuthUser();
    		$log .= 'User #' . $person['id'] . ' ' . format::personFullName($person) . ': ';
    	}
    	else {
    		$log .= 'Unknown user: ';
    	}
    	
    	Kohana::log($level, $log . $message);
    }
    
    public static function securityInfo($message) {
    	self::security('info', $message);
    }
}
